const API_URL = 'http://localhost:90/';

/**
 * 封装ajaxpost函数
 * @param {any} opt
 */
function ajaxpost(opt) {
	opt = opt || {};
	opt.url = opt.url || '';
	opt.data = opt.data || null;
	opt.success = opt.success || function() {};
	$.ajax({
		url: API_URL + opt.url,
		type: 'post',
		contentType: 'application/json',
		data: JSON.stringify(opt.data),
		success: function(data) {
			opt.success(data);
		},
		error: function(XMLHttpRequest) {
			var state = XMLHttpRequest.status;
			console.log(state);

		}
	})

}
/**
 * 封装ajaxget函数
 * @param {any} opt
 */
function ajaxget(opt) {
	opt = opt || {};
	opt.url = opt.url || '';
	opt.success = opt.success || function() {};
	$.ajax({
		url: API_URL + opt.url,
		type: 'get',
		contentType: 'application/json',
		success: function(data) {
			opt.success(data);
		},
		error: function(XMLHttpRequest) {
			var state = XMLHttpRequest.status;
			console.log(state);
		}
	})
}